
//? 这个方法是获取嵌套层数
Array.prototype.myGetLevel2 = function () {
    let max = 1
    for (const item of this) {
        if (Object.prototype.toString.call(item).includes('Array') || Object.prototype.toString.call(item).slice(8).includes('Object')) {
            if (Object.prototype.toString.call(item).includes('Array')) {
                const depth = item.myGetLevel2() + 1
                if (depth > max) max = depth
            }
        }
    }
    return max
}
const arr = [1, [2, 3, [4, 5, [10, 12]]], 1, 2, [6, 7]]
console.log(arr.myGetLevel2())
